package com.neusoft.crm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.crm.mapper.ClientLinkManMapper;
import com.neusoft.crm.mapper.ClientReprieveLoseMapper;
import com.neusoft.crm.po.ClientInfo;
import com.neusoft.crm.po.ClientLinkMan;
import com.neusoft.crm.po.ClientReprieveLose;
import com.neusoft.crm.po.SysUser;
import com.neusoft.crm.service.ClientLinkManService;
import com.neusoft.crm.service.ClientReprieveLoseService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ClientReprieveLoseController {

    @Resource
    private ClientReprieveLoseService clientReprieveLoseService;
    @Resource
    private ClientReprieveLoseMapper clientReprieveLoseMapper;

    @RequestMapping("/saveNewChurnPlan")
    public int saveNewChurnPlan(@RequestBody ClientReprieveLose clientReprieveLose){
        return clientReprieveLoseMapper.insert(clientReprieveLose);
    }

    @RequestMapping("/selectAllHistoryPlan")
    public List<ClientReprieveLose> selectAllHistoryPlan(@RequestBody ClientReprieveLose clientReprieveLose) {
        String id =clientReprieveLose.getClientCode();
        LambdaQueryWrapper<ClientReprieveLose> queryWrap=new LambdaQueryWrapper<>();
        queryWrap.eq(ClientReprieveLose::getClientCode, id);
        return clientReprieveLoseMapper.selectList(queryWrap);
    }

    @RequestMapping("/churnPlanDelete")
    public int churnPlanDelete(@RequestBody ClientReprieveLose clientReprieveLose){
        return clientReprieveLoseMapper.deleteById(clientReprieveLose);
    }

    @RequestMapping("/updateChurnPlanInfo")
    public int updateChurnPlanInfo(@RequestBody ClientReprieveLose clientReprieveLose) {
        return clientReprieveLoseMapper.updateById(clientReprieveLose);
    }
}
